# Contributor: Adrian L Lange <alpine@p3lim.net>
# Contributor: Charles Wimmer <charles@wimmer.net>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer: Dermot Bradley <dermot_bradley@yahoo.com>
pkgname=step-cli
pkgver=0.25.1
pkgrel=0
pkgdesc="Zero trust swiss army knife that integrates with step-ca for automated certificate management"
url="https://github.com/smallstep/cli"
arch="all !riscv64" # ftbfs
license="Apache-2.0"
makedepends="
	bash
	go
	go-bindata
	"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/smallstep/cli/archive/refs/tags/v$pkgver.tar.gz
	01-fix-tests.patch
	"
builddir="$srcdir/cli-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make build
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 autocomplete/bash_autocomplete \
		"$pkgdir"/usr/share/bash-completion/completions/step

	install -Dm644 autocomplete/zsh_autocomplete \
		"$pkgdir"/usr/share/zsh/site-functions/_step
}

sha512sums="
fd9e277b254a58d456595f8a7ff14a943381b87fc4ba8ca594e71d5076a9d91eda6463034b4a99761eca5697e2e9391ec625aacb3e665bce3bda2b73349316a7  step-cli-0.25.1.tar.gz
3902f18ca36ee379c7d67fa990d505c43fcbdedb3dab5a1a42ea356be45961c57e81f5906eb93b93d92abbe3a6f7ae70d8a92407460886920c1d9a3a58bf81f7  01-fix-tests.patch
"
